Render subcomponents in get-documentation#209
Conversation
🦋 Changeset detectedLatest commit: f59e38c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for storybook-mcp-self-host-example canceled.
|
commit: |
Bundle ReportChanges will decrease total bundle size by 58.74kB (-52.32%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: @storybook/addon-mcp-esmAssets Changed:
view changes for bundle: @storybook/mcp-esmAssets Changed:
Files in
|
❌ 4 Tests Failed:
View the full list of 4 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
…/render-subcomponents-in-get-documentation
There was a problem hiding this comment.
Pull request overview
Updates the @storybook/mcp get-documentation markdown output to include manifest-defined subcomponents, allowing MCP consumers to see child component APIs inline in the generated documentation.
Changes:
- Extend the MCP manifest schema to accept
subcomponentsonComponentManifest. - Add a
## Subcomponentsmarkdown section (with per-subcomponent import/description/props/errors) to the manifest formatter. - Update unit tests for the formatter and get-documentation tool; also bumps Storybook-related dependency versions and regenerates lockfiles.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Bumps Storybook-related catalog versions (alpha.2 → alpha.6). |
| packages/mcp/src/utils/manifest-formatter/markdown.ts | Adds subcomponents rendering and refactors props formatting into a reusable helper. |
| packages/mcp/src/utils/manifest-formatter/markdown.test.ts | Adds formatter tests covering the new subcomponents markdown output. |
| packages/mcp/src/types.ts | Extends Valibot schemas/types to include SubcomponentManifest and ComponentManifest.subcomponents. |
| packages/mcp/src/tools/get-documentation.test.ts | Adds a tool-level snapshot asserting subcomponents are included in get-documentation output. |
| packages/addon-mcp/pnpm-lock.yaml | Lockfile updates due to dependency bumps. |
| eval/pnpm-lock.yaml | Lockfile updates due to dependency bumps (incl. vite-plugin-react-docgen-typescript). |
| apps/internal-storybook/pnpm-lock.yaml | Lockfile updates due to dependency bumps (internal Storybook app). |
| const parsedDocgen = getParsedDocgen(subcomponent); | ||
| const typeName = `${(subcomponent.name || key).replace(/\W+/g, '')}Props`; | ||
| parts.push(...formatPropsSection(parsedDocgen, { title: '#### Props', typeName })); |
There was a problem hiding this comment.
typeName for subcomponent props is derived from the subcomponent name/key by stripping non-word characters, but it can still produce an invalid TypeScript identifier (e.g., names starting with a digit). Since this is emitted as a TS-like type alias in the markdown, consider normalizing to a valid identifier (e.g., prefix with _ when the first char isn’t [A-Za-z_], and fall back to a safe default when the sanitized name is empty).
Summary
This updates
get-documentationto render manifestsubcomponentsin the markdown response, so agents can see child component APIs directly from MCP output instead of needing to infer them from stories alone.What changed
subcomponents## Subcomponentssection in the markdown formatterValidation
pnpm vitest run --project=@storybook/mcp packages/mcp/src/tools/get-documentation.test.ts packages/mcp/src/utils/manifest-formatter/markdown.test.tspnpm --filter @storybook/mcp build